
/* ###############################################

		1. Written date 		>> 	2007. 1. 29
		2. File Name 		>> 	ClientMGR.h
 		3. Contents 		>>	서버의 소켓 관리 매니저 클래스...
 		4. Written by 		>>	최철호	
 		5. Last Revision Date	>>	2007. 1. 29
										
################################################ */


#ifndef _CLIENTMGR_H
#define _CLIENTMGR_H

#include <unistd.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pthread.h>

#include "Client.h"
#include "Array.h"

typedef struct _transferMessage {
//	int type;
	char contents[256];
	int type;
} TransferMessage;


class ClientMGR
{
public:
	//////////////////////////////
	// Constructor & Destructor	//
	//////////////////////////////
	
	//Constructor
	ClientMGR( int lines = 100 );

	//Destructor
	virtual ~ClientMGR();

	//Copy Constructor
	ClientMGR(const ClientMGR& source);


	//////////////////////////////
	// Operators				//
	//////////////////////////////
	
	// = Operator
	ClientMGR& operator = (const ClientMGR& source);

	// [] Operator
	Client& operator [] (int index);

	// + Operator
	Client* operator + (int index);

	//////////////////////////////
	// Member Functinos			//
	//////////////////////////////
	
	//Record
	int Record( string ipAddress, PSocket* clientSocket );
	
	//Record
	Client* Record( PSocket* clientSocket, string ipAddress );
	
	// find
	int FindClient( Client* client ); 
	
	// 클라이언트 접송 종료 관리....
	void DisConnectClient( int index );

	// PUB Request Handler Function...
	void OnCheckMacAddress( Client* client, TransferMessage transferMessage );
	void OnCheckURL( Client* client, TransferMessage transferMessage );
	void OnCheckTAG( Client* client, TransferMessage transferMessage );

	
	//Get Lines
	int GetLines() const;

private:
	int lines;
	Array<Client> clients;

};

inline int ClientMGR::GetLines() const
{
	return this->lines;
}

#endif // _CLIENTMGR_H
